package org.slf4j.impl;

import java.io.IOException;

import org.slf4j.Logger;
import org.slf4j.Marker;

import com.db.mylogging.FileAppender;
import com.db.mylogging.Level;
import com.db.mylogging.MyLogger;

public class MyLoggerAdapter implements Logger {

	private static final String ERR_NOT_IMPLEMENTED = "method not implemented";
	
	private final MyLogger logger;
	
	public MyLoggerAdapter(String name) {
		logger = new MyLogger(name);
		try {
			logger.addAppender(new FileAppender("log_slf4j.txt", false));
		} catch (IOException e) {
			throw new RuntimeException("Failed to setup logger", e);
		}
	}
	
	private String format(String arg0, Object arg1) {
		return arg0.replace("{}", arg1.toString());
	}
	
	@Override
	public void debug(String arg0) {
		logger.debug(arg0);
	}

	@Override
	public void debug(String arg0, Object arg1) {
		logger.debug(format(arg0, arg1));
	}

	@Override
	public void debug(String arg0, Object... arg1) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void debug(String arg0, Throwable arg1) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void debug(Marker arg0, String arg1) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void debug(String arg0, Object arg1, Object arg2) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void debug(Marker arg0, String arg1, Object arg2) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void debug(Marker arg0, String arg1, Object... arg2) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void debug(Marker arg0, String arg1, Throwable arg2) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void debug(Marker arg0, String arg1, Object arg2, Object arg3) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void error(String arg0) {
		logger.error(arg0);
	}

	@Override
	public void error(String arg0, Object arg1) {
		logger.debug(format(arg0, arg1));
	}

	@Override
	public void error(String arg0, Object... arg1) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void error(String arg0, Throwable arg1) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void error(Marker arg0, String arg1) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void error(String arg0, Object arg1, Object arg2) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void error(Marker arg0, String arg1, Object arg2) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void error(Marker arg0, String arg1, Object... arg2) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void error(Marker arg0, String arg1, Throwable arg2) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void error(Marker arg0, String arg1, Object arg2, Object arg3) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public String getName() {
		return logger.getName();
	}

	@Override
	public void info(String arg0) {
		logger.info(arg0);
	}

	@Override
	public void info(String arg0, Object arg1) {
		logger.info(format(arg0, arg1));
	}

	@Override
	public void info(String arg0, Object... arg1) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void info(String arg0, Throwable arg1) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void info(Marker arg0, String arg1) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void info(String arg0, Object arg1, Object arg2) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void info(Marker arg0, String arg1, Object arg2) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void info(Marker arg0, String arg1, Object... arg2) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void info(Marker arg0, String arg1, Throwable arg2) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void info(Marker arg0, String arg1, Object arg2, Object arg3) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public boolean isDebugEnabled() {
		return logger.getLoggerLevel().getValue() >= Level.DEBUG.getValue();
	}

	@Override
	public boolean isDebugEnabled(Marker arg0) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public boolean isErrorEnabled() {
		return logger.getLoggerLevel().getValue() >= Level.ERROR.getValue();
	}

	@Override
	public boolean isErrorEnabled(Marker arg0) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public boolean isInfoEnabled() {
		return logger.getLoggerLevel().getValue() >= Level.INFO.getValue();
	}

	@Override
	public boolean isInfoEnabled(Marker arg0) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public boolean isTraceEnabled() {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public boolean isTraceEnabled(Marker arg0) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public boolean isWarnEnabled() {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public boolean isWarnEnabled(Marker arg0) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void trace(String arg0) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void trace(String arg0, Object arg1) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void trace(String arg0, Object... arg1) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void trace(String arg0, Throwable arg1) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void trace(Marker arg0, String arg1) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void trace(String arg0, Object arg1, Object arg2) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void trace(Marker arg0, String arg1, Object arg2) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void trace(Marker arg0, String arg1, Object... arg2) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void trace(Marker arg0, String arg1, Throwable arg2) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void trace(Marker arg0, String arg1, Object arg2, Object arg3) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void warn(String arg0) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void warn(String arg0, Object arg1) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void warn(String arg0, Object... arg1) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void warn(String arg0, Throwable arg1) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void warn(Marker arg0, String arg1) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void warn(String arg0, Object arg1, Object arg2) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void warn(Marker arg0, String arg1, Object arg2) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void warn(Marker arg0, String arg1, Object... arg2) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void warn(Marker arg0, String arg1, Throwable arg2) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}

	@Override
	public void warn(Marker arg0, String arg1, Object arg2, Object arg3) {
		throw new UnsupportedOperationException(ERR_NOT_IMPLEMENTED);
	}
}
